<!DOCTYPE html>
<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<meta name="renderer" content="webkit" />
	<meta http-equiv="Pragma" content="no-store" />
	<meta http-equiv="Access-Control-Allow-Origin" content="*">

    <link href="../../css/bootstrap.css" rel="stylesheet" />
    <link href="../../css/cover.css" rel="stylesheet" />
    <link href="../../css/font-awesome.min.css" rel="stylesheet" />
    <title>荆州千网汇信息科技有限公司</title>
    <script src="../../js/jquery-2.2.3.min.js"></script>
    <script src="../../js/jquery.flexslider-min.js"></script>
    <script src="../../js/rem.js"></script>
    <script src="../../js/itnetcao.js"></script>

    <link href="../../js/layui/css/layui.css" rel="stylesheet" />

    <link href="../../js/donghua/animsition.min.css" rel="stylesheet" />
    <script src="../../js/donghua/animsition.min.js"></script>
    <link rel="stylesheet" href="../../css/minirefresh.css" />
    <link rel="stylesheet" href="../../css/common.css" />
    <script type="text/javascript" src="../../js/minirefresh.js"></script>
    <script type="text/javascript" src="../../js/common.js"></script>


		<title>machine</title>
		<style type="text/css">
			*{
				margin: 0;padding: 0;
			}
	      	body{
		        font-family:"微软雅黑";
		    }
			.main{
				width: 100%;
			}
			.head{
				font-size: 0.6rem;
				width: 100%;
				height: 1.8rem;
				line-height: 2.2rem;
				background-color: #FFB800;
			}
			a{
				text-decoration: none;
				color: black;
			}
			.head p{
				position: relative;
				left: 3.9rem;
			}
			.head span{
			 	position: relative;
				left: -3.5rem;
				top: 0.1rem;
				color: black;
			}
			.machine{
				width: 80%;
				height: 6rem;
				background-color: white;
				margin-left: 10%;
				margin-top: 1rem;
				box-shadow: 1px 3px 12px rgba(96,96,96,0.5);
				font-size: 0.4rem;
				text-align: center;
			}
			.machine img{
				margin-top: 0.5rem;
				margin-bottom: 0.2rem;
				border: none;
			}
			.machine input{
				margin-top: 0.2rem;
				padding: 0.1rem;
				background-color:  #FFB800;
			}
		</style>
	</head>
	<body style='width:100%;'>

		<div class="page_top01 relative">
            <h3 class="text-center">矿机</h3>
            <a href="javascript:;" class="animsition-link" data-animsition-out-class="fade-out-right" data-animsition-out-duration="500" onclick="history.go(-1)">
                <img src="../../images/icon_left.png" class="img-responsive reture_img" /></a>

        </div>

		<div class="main" style='width:100%;overflow-y:scroll'>

		</div>
	</body>


<script type='text/javascript'>


$(".main").css({"height" : ($(window).height() - 60 - 60) + "px"});

var userId = jQuery.parseJSON(localStorage.getItem("miningmachine_user")).userId;
$(function() {
	$("#start").click(function() {
		var url = localStorage.getItem("url") + "/dug/controller/DugMoneyFindAllAPP.do",
		data = "";
	})
})

// 获取我的矿机
var url = localStorage.getItem("url") + "/dug/controller/DugMoneyFindAllAPP.do";
var data = "userId=" + userId;
itcao.itGetAjaxBigData(url, data).done(function(result) {
	var json = jQuery.parseJSON(result).bean;

	$(".machine").remove();
	if(json) {
		for(var i=0; i<json.length; i++) {
			var imageUrl = "";
			var headTitle = "";
			if(json[i].dugType == 1) {
				imageUrl = "../../image/weixing.jpg";
				headTitle = "迷你";
			}
			if(json[i].dugType == 2) {
				imageUrl = "../../image/chuji.jpg";
				headTitle = "初级";
			}
			if(json[i].dugType == 3) {
				imageUrl = "../../image/zhongji.jpg";
				headTitle = "中级";
			}
			if(json[i].dugType == 4) {
				imageUrl = "../../image/gaoji.jpg";
				headTitle = "高级";
			}
			var butText = "启动";
			var go = "";
			if(json[i].dugIsStart == 1) {
				butText = "已启动";
				go = "运行中...";
			}else {
				butText = "启动";
				go = "未运行...";
			}
			$(".main").append("" +
				"<div class='machine'>" +
					"<img src='"+imageUrl+"' width='180' height='130'/>" +
					"<p>类型:"+headTitle + "</p>" +
					"<p class='zhuangtai"+json[i].dugId+"'>状态:" + go + "</p>" +
					"<p style='font-size:0.3rem;'>起始:" + json[i].dugDate.substring(0, 11) + "</p>" +
					"<p style='font-size:0.3rem;'>终止:" + GetDateStr(json[i].dugDate, 25) + "</p>" +
					"<div align='center' style='margin-top:20px;'><button onclick='minerStart(\""+json[i].dugId+"\")' class='layui-btn layui-btn-warm btn"+json[i].dugId+"' style='width:80px;'>"+butText+"</button></div>" +
				"</div>" +
			"")
		}
	}
})
function GetDateStr(date, AddDayCount) {
   var dd = new Date(date);
   dd.setDate(dd.getDate()+AddDayCount);
   var y = dd.getFullYear();
   var m = (dd.getMonth()+1)<10?"0"+(dd.getMonth()+1):(dd.getMonth()+1);
   var d = dd.getDate()<10?"0"+dd.getDate():dd.getDate();
   return y+"-"+m+"-"+d;
}
var shiming = false;
function desc(dugIGo) {
	if(!shiming) {
		alert("您没有实名认证,矿机无法启动.");
		return;
	}
	if($(".btn" + dugIGo).text() == "已启动") {
		localStorage.setItem("kuang_ji_id_desc", dugIGo);
		window.location.href = "machineDesc.html";
	}
}


function minerStart(dugIGo) {
	if(!shiming) {
		alert("您没有实名认证,矿机无法启动.");
		return;
	}
	if($(".btn" + dugIGo).text() != "启动") {
		alert("矿机运行中...");
		return;
	}
	var url = localStorage.getItem("url") + "/dug/controller/DugMoneyStartAPP.do";
	var data = "duyId=" + dugIGo + "&userId=" + userId;
	itcao.itGetAjaxBigData(url, data).done(function(result) {
		var json = jQuery.parseJSON(result);
		if(json.state == true) {
			alert("启动成功.");
			$(".zhuangtai" + dugIGo).text("状态:运行中...");
			$(".btn" + dugIGo).text("已启动");
		}else {
			alert("启动失败:" + json.value);
		}
	})
}

// 获取用户实名认证信息
var url = localStorage.getItem("url") + "/user/controller/UserFindIdentityAuthenticationAPP.do";
var data = "userId=" + userId;
itcao.itGetAjaxBigData(url, data).done(function(result) {
	var json = jQuery.parseJSON(result);
	if(json.state == true) {
		if(json.bean.authExamine == 1) {
			shiming=true;
		}
	}
})

</script>
</html>
